#{set _items : commodities /}
#{set page : _page /}
#{set pageSize : _pageSize /}
#{set totalCount : _totalCount /}

<div id="commodity-table">
	<table class="common-table">
		<thead>
			<tr>
				<th>ID</th>
				<th>商品名称</th>
				<th>商品编号</th>
				<th>厂商标号</th>
			</tr>
		</thead>
		<tbody>
			#{list items:_items, as:'commodity'}
			<tr>
				<th><a href="#">${commodity.id}</a></th>
				<td><a href="#">${commodity.name}</a></td>
				<td>${commodity.SN}</td>
				<td>${commodity.manufacturerSN}</td>
			</tr>
			#{/list}
		</tbody>
	</table>
	
	<div id="pager"></div>
</div>

%{
	pageCount = (int)(totalCount / pageSize) + (totalCount % pageSize > 0 ? 1 : 0);
}%
<script>
$(function(){
	//初始化翻页控件。
	$("#pager").pager({
		pagenumber: ${page}, 
		pagecount: ${pageCount}, 
		totalcount: ${totalCount},
		buttonClickCallback: function(pageclickednumber) {
			//$("#currentPage").val(pageclickednumber);
			$.ajax({
				url: '@{admin.Commodities.admin_index}',
				data: {
					page:pageclickednumber
				},
				success: function(data, textStatus){
					$("#commodity-table").replaceWith(data);
				}
			});
		}
	});
});
</script>

